package self;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.ParseException;

public class Fuxi {
    final int d = 0;
    public static void main(String[] args) throws ParseException, IOException {
        int a = 0;
        System.out.println(a);
//        show();
//        System.out.println(new A());
        String s = "hello";
        String s1 = "你好";
        String s2 = "吗";
        String s3 = "你好吗";
        String t = new String("hello");
        System.out.println(s==t);
        System.out.println(s3==(s1+s2));
    }

    static String s = "dfa";
    static class A{
        public A(){
            System.out.println(this);
        }
    }
    public static void show() throws IOException {
//        File file = new File("D:\\");
//        fun(file);
//        RAFWrite();
//        RAFRead();

    }

    public static void RAFRead() throws IOException {
        RandomAccessFile raf = new RandomAccessFile("E:\\rafread.txt","r");
        System.out.println("当前指针位置 "+raf.getFilePointer());
        for (int i = 0; i < 4; i++) {
            System.out.println("读取 "+raf.readChar());
            System.out.println("当前指针位置 "+raf.getFilePointer());
        }
//        byte[] bytes = {'J','a','c','k','i','e','0','0','0','0'};
//        String string = new String(bytes,"utf-8").trim();
        raf.seek(1);
        System.out.println("改后指针位置 "+raf.getFilePointer());
        System.out.println("读 "+raf.readChar());
        System.out.println("读后指针位置 "+raf.getFilePointer());
        raf.close();
    }

    public static void RAFWrite() throws IOException {
        RandomAccessFile raf = new RandomAccessFile("E:\\rafread.txt", "rw");
        System.out.println("当前指针位置" + raf.getFilePointer());
        String[] string = "成龙大哥".split("");
//        String str = "fdja";
//        str.getBytes("utf-8");
        char[] chars = "成龙大哥".toCharArray();
        for (int i = 0; i < chars.length; i++) {
            raf.writeChar(chars[i]);
//            System.out.println("当前指针位置" + raf.getFilePointer());
//            System.out.println("文件长度" + raf.length());
        }
//        raf.writeUTF("陈港生最帅");
        raf.close();
    }

    public static void fun(File file){
        // 创建匿名内部类
        FileFilter filter = new FileFilter() {
            @Override
            // 重写 accept 方法
            public boolean accept(File pathname) {
                String name = pathname.getName();
                return name.endsWith(".exe");
            }
        };
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()){
                // 以过滤器规则返回file数组
                File[] filtor= files[i].listFiles(filter);
                // 遍历
                for (File file1 :filtor) {
                    System.out.println(file1.getName());
                }
                fun(files[i]);
            }
            else{
                String fileName = files[i].getName();
                if (fileName.endsWith(".exe")){
                    System.out.println(files[i].getName());
                }
            }
        }
    }

}

interface jiekou{
   void fang();
   static void fd(){
       System.out.println(213);
   }
}
class lei implements jiekou{
    @Override
    public void fang() {

    }
    static public void ds(){
        System.out.println("ds");
    }
    public void dds(){
        System.out.println("dds");
    }
}

class zi extends lei{
    public static void ds(){
        System.out.println("zids");
    }
    @Override
    public void dds(){
        System.out.println("zidds");
    }
}
